package org.sample.springbootactivemq.web;

import org.sample.springbootactivemq.queue.MessageSender;
import org.sample.springbootactivemq.web.model.MessageRequest;
import org.sample.springbootactivemq.web.model.MessageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/message")
public class MessageController {

	@Autowired
	private MessageSender messageSender;

	@PostMapping("/text")
	public MessageResponse sendMessage(@RequestBody MessageRequest request) {

		messageSender.send(request.getMessage());

		MessageResponse response = new MessageResponse();
		response.setSuccess(true);
		return response;
	}

}
